<?php
/**
 * shortcut.php
 *
 * @author Di Zhang <zhangdi_me@163.com>
 * @link http://zhangdi.me/
 */

/**
 * @return CWebApplication
 */
function app()
{
    return Yii::app();
}

/**
 * @return string
 */
function base_url()
{
    return Yii::app()->getBaseUrl();
}

/**
 * @return string
 */
function base_path()
{
    return Yii::app()->getBasePath();
}

/**
 * @return CClientScript
 */
function cs()
{
    return Yii::app()->getClientScript();
}

/**
 * @return CWebUser
 */
function user()
{
    return Yii::app()->getUser();
}

/**
 * @param string $route
 * @param array $params
 * @return string
 */
function url($route, $params = array())
{
    return Yii::app()->createAbsoluteUrl($route, $params);
}

/**
 * @param string $message
 * @param string $category
 * @param array $params
 * @param string $source
 * @param string $language
 * @return string
 */
function t($message, $category = 'stay', $params = array(), $source = null, $language = null)
{
    return Yii::t($category, $message, $params, $source, $language);
}

/**
 * @param string $name
 * @return mixed
 */
function param($name = null)
{
    if ($name == null) {
        return Yii::app()->params;
    } else {
        return Yii::app()->params[$name];
    }
}